package com.digitalchina.lxnsy.activity.old;

import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import androidx.legacy.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.ViewGroup;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.fragment.PeriodCurrentFragment;
import com.digitalchina.lxnsy.fragment.PeriodHistoryFragment;
import com.kekstudio.dachshundtablayout.DachshundTabLayout;
import com.kekstudio.dachshundtablayout.indicators.LineMoveIndicator;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2017/7/31 10:34
 * 修改备注：
 * ================================================
 */
public class FamousInterviewActivity extends BaseActivity {

    private static final String DOG_BREEDS[] = {"本期", "往期"};

    @Bind(R.id.tab_layout)
    DachshundTabLayout tabLayout;
    @Bind(R.id.view_pager)
    ViewPager viewPager;

    private ArrayList<Fragment> list = new ArrayList<>();

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_famous_interview);
        setTitle("农家专访");
    }

    @Override
    public void initMember() {

        tabLayout.setAnimatedIndicator(new LineMoveIndicator(tabLayout));

        list.add(new PeriodCurrentFragment());
        list.add(new PeriodHistoryFragment());

        viewPager.setAdapter(new PagerAdapter(getFragmentManager()));
        tabLayout.setupWithViewPager(viewPager);

    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    public class PagerAdapter extends FragmentPagerAdapter {

        public PagerAdapter(FragmentManager fm) {
            super(fm);
        }


        @Override
        public Fragment getItem(int position) {

            return list.get(position);
        }

        @Override
        public int getCount() {

            return list.size();
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return DOG_BREEDS[position];
        }
    }
}
